package com.coisini.mapper;

import com.coisini.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;


import java.util.List;

@Mapper
public interface SetmealDishMapper {

    /**
     * 根据菜品id查询关联的套餐
     * 使用聚合函数，统计总个数即可
     * @param ids
     * @return
     */
    Integer getByIds(List<Long> ids);

    /**
     * 根据菜品id查询关联的套餐
     * @param dishId
     */
    @Select("select setmeal_id from setmeal_dish where dish_id =#{dishId}")
    List<Long> getById(Long dishId);

    /**
     *新增套餐-菜品关系
     * @param setmealDish
     */
    void insert(SetmealDish setmealDish);

    /**
     * 根据套餐id查询套餐-菜品对应信息
     * @param setmealId
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id =#{setmealId}")
    List<SetmealDish> getBySetmealId(Long setmealId);


    /**
     * 根据套餐id批量删除数据
     * @param setmealId
     */
    @Delete("delete from setmeal_dish where setmeal_id =#{setmealId}")
    void delete(Long setmealId);
}
